﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DelonixRegiaHMSys.Core.Services;
using DelonixRegiaHMSys.Infrastructure.Data;

namespace DelonixRegiaHMSys.UI.WebForms
{
    public partial class Administrator : System.Web.UI.Page
    {
        string userID;
        protected void Page_Load(object sender, EventArgs e)
        {
            userID = Request.QueryString["UserID"];
            var saservice = new saServices(new EfSystemAccountQuery());
            bool IsAdmin = saservice.IsAdmin(userID);
            if (IsAdmin == true)
            {
                lsambtn.Visible = true;
            }
            else
            {
                lsambtn.Visible = false;
            }
        }

        protected void lsambtn_Click(object sender, EventArgs e)
        {
            Server.Transfer("~/WebForms/SystemAccountModule/SystemAccountManagement.aspx?UserID=" + userID);
        }

        protected void lrbtn_Click(object sender, EventArgs e)
        {
            Server.Transfer("~/WebForms/COandReportingModule/ReportsManagement.aspx?UserID=" + userID);
        }

        protected void lsbtn_Click(object sender, EventArgs e)
        {
            Server.Transfer("~/WebForms/HousekeepingandStaffModule/StaffManagement.aspx?UserID=" + userID);
        }

        protected void MainpageBtn_Click(object sender, EventArgs e)
        {
            Server.Transfer("~/WebForms/SystemAccountModule/Mainpage.aspx?UserID=" + userID);
        }

        protected void Logoutbtn_Click(object sender, EventArgs e)
        {
            Session["User"] = false;
            var saservice = new saServices(new EfSystemAccountQuery());
            saservice.UpdateUserStatus(userID, "OFF");
            Response.Redirect("~/WebForms/SystemAccountModule/LoginPage.aspx", true);
        }
    }
}